package com.one.blocks.rbac.config;

import com.one.blocks.rbac.log.LogAspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * @author linfuxin Created on 2022-02-14 11:22:15
 */
@Configuration
@ConditionalOnProperty(prefix = "app.blocks.log", name = "enable", havingValue = "true", matchIfMissing = true)
public class LogConfig {

    @Bean
    @ConditionalOnMissingBean(LogAspect.class)
    public LogAspect logAspect(DataSource dataSource) {
        // TODO 改为参数化配置
        return new LogAspect(1024 * 8, dataSource);
    }
}
